package com.dlb.andorid.presenter;

import com.dlb.andorid.XAPI;
import com.dlb.andorid.XContract;
import com.dlb.andorid.XPresenter;
import com.dlb.andorid.XServerMsg;
import com.dlb.andorid.bean.ArgPayOrder;

import java.util.HashMap;

public class OrderPayPresenter extends XPresenter {
	XContract.IOrderPayView iView;

	public OrderPayPresenter(XContract.IOrderPayView iView) {
		super(iView);
		this.iView = iView;
	}

	public void payOrder(ArgPayOrder arg) {
		mModel.payOrder(arg);
	}

	public void getAddressFee(long province_id, long city_id) {
		mModel.getAddressFee(province_id, city_id);
	}

	@Override
	public void onDataSuccess(int vocational_id, HashMap<String, Object> exData, Object data) {
		super.onDataSuccess(vocational_id, exData, data);
		switch (vocational_id) {
			case XAPI.PAY_ORDER_VOCATIONAL_ID:
				iView.payOrderSuccess((XServerMsg) data);
				break;
			case XAPI.GET_ADDRESS_TOTAL_FEE_VOCATIONAL_ID:
				iView.getAddressFeeSuccess(((XServerMsg<Float>) data).getData());
				break;
		}
	}


}
